package com.zyj.test.month1.day14;

/**
 * @author Yijia Zhang
 * @create 2024-06-01 00:44
 */
public class code2928 {
    int res = 0;
    public int distributeCandies(int n, int limit) {
        backTrack(0, n, limit);
        return res;
    }
    private void backTrack(int idx, int now, int limit) {
        if (idx == 2) {
            if (now <= limit)
                res++;
            return;
        }
        int min = Math.min(now, limit);
        for (int i = 0; i <= min; i++) {
            backTrack(idx + 1, now - i, limit);
        }
    }
}
